#include <asm/uart.h>
.section ".text.boot"

.globl _start
_start:
	addi  sp, sp, -32
	sd ra, 24(sp)

	la a0, boot_string
	call uart_puts

	la a0, enter_string
	call uart_puts

	mv a0, sp
	call print_u64

	la a0, enter_string
	call uart_puts

#if 0
loop:
	li a0, 1000000
	call udelay
	la a0, enter_string
	call uart_puts
	j loop
#endif

#if 0
loop:
	la a0, file_buf
	li a1, 20480
	call lyn_uart_receive_packet
	bnez a0, loop
#endif

	
loop:
	la a0, file_buf
	li a1, 20480
	call xmodem_receive
	li t1, 6
	beq t1, a0, RET
	bnez a0, loop

RET:
	ld ra, 24(sp)
	addi sp, sp, 32
	ret

.section .data
.align  12
.global stacks_start
stacks_start:
	.skip 4096

.section .rodata
.align 3
.global boot_string
boot_string:
	.string "Booting at asm!!!!\r\n"

.global enter_string
enter_string:
	.string "d\r\n"

.section .data
.align 3
.global file_buf
file_buf:
	.zero 20480
